package com.hyw.cm.protocal.driver.tbit;

import java.time.Duration;

import com.hyw.cm.common.protocal.spi.IDecoder;
import com.hyw.cm.common.protocal.spi.IEncoder;
import com.hyw.cm.common.protocal.spi.IProtocalDriver;

import io.netty.handler.codec.ByteToMessageDecoder;

/**
 * 泰比特协议的驱动
 * <p>
 * 协议详情参照：{@link http://doc.tbit.com.cn/terminal/WA-206_ECU/ECU%E4%B8%AD%E6%8E%A7%E4%B8%8E%E4%BA%91%E5%B9%B3%E5%8F%B0%E9%80%9A%E8%AE%AF%E5%8D%8F%E8%AE%AE_V1.3.0.html}
 * 
 * @author Hongyu
 */
public final class TBitProtocalDriver implements IProtocalDriver {

  // 协议中，心跳包是2分钟，则服务端允许为3分钟超时
  private static final Duration HEARTBEAT_INTERVAL = Duration.ofMinutes(3);

  private final TBitDecoder decoder = new TBitDecoder();

  @Override
  public IDecoder<ByteToMessageDecoder> getDecoder() {
    return decoder;
  }

  @Override
  public IEncoder getEncoder() {
    // TODO Auto-generated method stub
    return null;
  }

  @Override
  public Duration getReadTimeout() {
    return HEARTBEAT_INTERVAL;
  }
}
